package com.boot.modules.admin.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.boot.common.enums.OrderEnums;
import com.boot.modules.admin.dao.OrderMapper;
import com.boot.modules.admin.service.OrderService;
import com.boot.notes.rocketmq.OrderBean;
import com.boot.notes.rocketmq.transactionMsg.entity.Order;
import org.apache.rocketmq.client.producer.TransactionSendResult;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;


/**
 * @className: OrderServiceImpl
 * @auther: mkq
 * @date: 2022/01/22 10:29
 * @desctiption: TODO
 * @version: 1.0
 */
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;



    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateOrderState(Long orderId, String orderState) {
        Order order = new Order();
        order.setId(orderId);
        order.setOrderState(orderState);
        order.setGmtModified(new Date());
        return this.baseMapper.updateById(order);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void submit(Order order) {
        order.setGmtCreate(new Date());
        order.setGmtModified(new Date());
        this.baseMapper.insert(order);
    }
}
